<?php 

$con= mysql_connect("localhost","root","");
if(!$con){
die('Connection Error!:' . mysql_error());
}
mysql_select_db ("usabilityevaluation",$con);


$idP = $_POST["id"];
$lastName = mysql_real_escape_string(htmlspecialchars(stripcslashes($_POST["textlastname"])));
$firstName = mysql_real_escape_string(htmlspecialchars(stripcslashes($_POST["textfirstname"])));
$comment = mysql_real_escape_string(htmlspecialchars(stripcslashes($_POST["textareaComment"])));
$sexe = mysql_real_escape_string(htmlspecialchars(stripcslashes($_POST["sex"])));
$rightHanded = mysql_real_escape_string(htmlspecialchars(stripcslashes($_POST["rightHanded"])));
if($sexe=="M")
	$sexe=1;
else
	$sexe=0;	

if($rightHanded=="Yes")
	$rightHanded=1;
else
	$rightHanded=0;

$query1="UPDATE Participant SET FirstName='$firstName', LastName='$lastName',  isMale='$sexe', isRightHanded='$rightHanded',Comment='$comment' where id_participant='$idP'";

$result = mysql_query($query1) or die('Error, modify query failed');

if (!$result) 
{
    die('Error, modify query failed' . mysql_error());
}
else {
//Si tout va bien, on informe que la modification est faite
echo "<script>alert('Modification succees!');</script>";
}
header("Location: ListeParticipants.php"); 
mysql_close($con);

?>